package removeHtmlTags;

public class RemoveHtmlTags {

	static String html = "<html><head><title></title></head><body class='scayt-enabled'>two comment</body></html>";
	
	public static String removeHTML(String input) {
		int i = 0;
		String[] str = input.split("");
		
		String s = "";
		boolean inTag = false;
		
		for (i=input.indexOf("<"); i<input.indexOf(">");i++){
			inTag = true;
		}
		if(!inTag){
			for(i=0;i<str.length;i++){
				s=s+str[i];
			}
		}
		return s;
	}
	
	public static void main(String[] args) {
		String s  = removeHTML(html);
		System.out.println(s);
		
		{
			String html2 = "<html><head><title></title></head><body class='scayt-enabled'>two comment</body></html>";
			String noHTMLString = html2.replaceAll("\\<.*?>","");
			System.out.println(noHTMLString);
		}
		{

			String html2 = "<html><head><title></title></head><body class='scayt-enabled'>" +
					"<p><span data-scayt_word='thrid' data-scaytid='1'>two</span> comment</p></body></html>";
			String noHTMLString = html2.replaceAll("\\<.*?>","");
			System.out.println(noHTMLString);
		}
		
		{
			// test case 2
			String html2 = "<html>\r\n\t<head>\r\n\t\t<title></title>\r\n\t</head>\r\n\t<body class='scayt-enabled'>\r\n\t</body>\r\n</html>\r\n";
			System.out.println("1=" + html2.length());
//			html2 = html2.replaceAll("\r", "");
//			System.out.println("2=" + html2.length());
			html2 = html2.replaceAll("\r|\n|\t", "");
			System.out.println("3=" + html2.length());
			String noHTMLString = html2.replaceAll("\\<.*?>","");
			System.out.println(noHTMLString);
			System.out.println("length="+noHTMLString.length());
		}
	}
}
//http://stackoverflow.com/questions/4432560/remove-html-tags-from-string-using-java
